<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .con{
            height: 30px;
            width: 500px;
            margin: 0 auto;
            background-color: #eee;
        }
        .pg{
            height: 30px;
            background: red;
            width: 100px;
        }
        </style>
</head>
<body>
    <div  class="con" id="con">
        <div  class="pg"  id="pg" style="width: 0px;">  </div>
        </div>

        <button   id="start"> 开始 </button>>
        <button   id="pasue"> 暂停 </button>
        <button   id="btn"> 打开新窗口 </button>
</body>
<script>
    var con = document.getElementById("con");
    var pg = document.getElementById("pg");
    var start = document.getElementById("start");
    var pasue = document.getElementById("pasue");

    var intervalId;
    start.onclick = function(){

        intervalId = setInterval(function(){
            var width = pg.style.width;
            width = parseInt(width)+1;
            pg.style.width = width+"px";
            if (width ==500) {
                clearInterval(intervalId);
            }
        },10)
    }


    pasue.onclick = function(){
        clearInterval(intervalId);

    }

    </script>
</html>